<div id="tab8" class="tab">
    <div class="tab-labels">
        <div class="xian"></div>
        本车人伤
    </div>
    <div id="div1">
        <table class="layui-table" id="tabProduct2">
            <tr style="background:#4e73df;color: #fff;" class="ys">
                <td style="width: 66px;">选择</td>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
                <td>户籍性质</td>
                <td>医疗机构</td>
                <td>病案号</td>
                <td>金额</td>
                <td>核价金额</td>
                <td>备注</td>
            </tr>
            {empty name="benren"}
            <tr>
                <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly value="">
                </td>
                <td><input type="text" name="name" readonly></td>
                <td><input type="text" name="sex" readonly></td>
                <td><input type="text" name="age" readonly></td>
                <td><input type="text" name="quality" readonly></td>
                <td><input type="text" name="nuit" readonly></td>
                <td><input type="text" name="number" readonly></td>
                <td><input type="text" name="money" readonly></td>
                <td><input type="text" name="hejia" readonly></td>
                <td><input type="text" name="beizhu" readonly></td>
            </tr>
            {/empty}
            {volist name='benren' id="benrens"}
            <tr>
                <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly
                           value="{$benrens.id}"></td>
                <td><input type="text" name="name" readonly value="{$benrens.name}" onclick="openDialogs1({$benrens.id})"
                           style='text-decoration: underline;color:blue;cursor: pointer;'></td>
                <td><input type="text" name="sex" readonly value="{$benrens.sex}"></td>
                <td><input type="text" name="age" readonly value="{$benrens.age}"></td>
                <td><input type="text" name="quality" readonly value="{$benrens.quality}"></td>
                <td><input type="text" name="nuit" readonly value="{$benrens.nuit}"></td>
                <td><input type="text" name="number" readonly value="{$benrens.number}"></td>
                <td><input type="text" name="money" readonly value="{$benrens.money}"></td>
                <td><input type="text" name="hejia" readonly value="{$benrens.hejia}"></td>
                <td><input type="text" name="beizhu" readonly value="{$benrens.beizhu}"></td>
            </tr>
            {/volist}
        </table>
        <table class="layui-table" id="he2">
            <tr>
                <td>小计</td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly id="benren_money" name="benren_money" value="{$row.benren_money}"></td>
                <td><input type="text" readonly id="benren_hejia" name="benren_hejia" value="{$row.benren_hejia}"></td>
                <td><input type="text" readonly></td>
            </tr>
        </table>
        <!--<p>汇总</p>-->
        <div class="conts" style="display: none">
            <div class="input">
                <span>费用合计</span>
                <input type="text" readonly value="{$row.br_heji}" name="br_heji">
            </div>
        </div>
        <div class="conts">
            <div class="input dong">
                <span>诉讼费</span>
                <input type="text" id="benren_susong" value="{$row.benren_susong}" name="benren_susong" readonly>
            </div>
            <div class="input dong">
                <span>鉴定费</span>
                <input type="text" id="benren_jianding" value="{$row.benren_jianding}" name="benren_jianding" readonly>
            </div>
            <div class="input dong">
                <span>公估费</span>
                <input type="text" id="benren_gonggu" value="{$row.benren_gonggu}" name="benren_gonggu" readonly>
            </div>
            <div class="input dong">
                <span>住宿费</span>
                <input type="text" id="benren_zhusu" value="{$row.benren_zhusu}" name="benren_zhusu" readonly>
            </div>
            <div class="input dong">
                <span>路桥费</span>
                <input type="text" id="benren_luqiao" value="{$row.benren_luqiao}" name="benren_luqiao" readonly>
            </div>
            <div class="input dong">
                <span>燃油费</span>
                <input type="text" id="benren_ranyou" value="{$row.benren_ranyou}" name="benren_ranyou" readonly>
            </div>
            <div class="input dong">
                <span>其他</span>
                <input type="text" id="benren_qita" value="{$row.benren_qita}" name="benren_qita" readonly>
            </div>
            <div class="input dong">
                <span>合计</span>
                <input type="text" id="benren_heji" value="{$row.benren_heji}" name="benren_heji" readonly>
            </div>
        </div>
        <div class="conts">
            <div class="input dong">
                <span>诉讼费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_susong"
                       value="{$benren[0]['hd_susong_fee']}" name="hd_benren_susong">
            </div>
            <div class="input dong">
                <span>鉴定费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_jianding"
                       value="{$benren[0]['hd_jianding_fee']}" name="hd_benren_jianding">
            </div>
            <div class="input dong">
                <span>公估费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_gonggu"
                       value="{$benren[0]['hd_gonggu_fee']}" name="hd_benren_gonggu">
            </div>
            <div class="input dong">
                <span>住宿费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_zhusu" value="{$benren[0]['hd_zhusu_fee']}"
                       name="hd_benren_zhusu">
            </div>
            <div class="input dong">
                <span>路桥费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_luqiao"
                       value="{$benren[0]['hd_luqiao_fee']}" name="hd_benren_luqiao">
            </div>
            <div class="input dong">
                <span>燃油费</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_ranyou"
                       value="{$benren[0]['hd_ranyou_fee']}" name="hd_benren_ranyou">
            </div>
            <div class="input dong">
                <span>其他</span>
                <input oninput="hd_benren_input()" type="text" id="hd_benren_qita" value="{$benren[0]['hd_qita_fee']}"
                       name="hd_benren_qita">
            </div>
            <div class="input dong">
                <span>合计</span>
                <input type="text" id="hd_benren_huizong"
                       value="{$benren[0]['hd_susong_fee']+$benren[0]['hd_jianding_fee']+$benren[0]['hd_gonggu_fee']+$benren[0]['hd_zhusu_fee']+$benren[0]['hd_luqiao_fee']+$benren[0]['hd_ranyou_fee']+$benren[0]['hd_qita_fee']}"
                       name="benren_heji">
            </div>
        </div>
        <div class="conts" style="text-align:center;">
<!--            <button type="button" onclick="baocun_benren_hd(this)">保存</button>-->
        </div>
        <script>
            function hd_benren_input() {
                var hd_benren_susong = $("#hd_benren_susong").val();
                var hd_benren_jianding = $("#hd_benren_jianding").val();
                var hd_benren_gonggu = $("#hd_benren_gonggu").val();
                var hd_benren_zhusu = $("#hd_benren_zhusu").val();
                var hd_benren_luqiao = $("#hd_benren_luqiao").val();
                var hd_benren_ranyou = $("#hd_benren_ranyou").val();
                var hd_benren_qita = $("#hd_benren_qita").val();
                var sum = Number(hd_benren_susong) + Number(hd_benren_jianding) + Number(hd_benren_gonggu) + Number(hd_benren_zhusu) + Number(hd_benren_luqiao) + Number(hd_benren_ranyou) + Number(hd_benren_qita);
                if (!isNaN(sum)) {
                    $("#hd_benren_huizong").val(sum.toFixed(2));
                }
            }

            function baocun_benren_hd(sub) {
                var bid = "{$orderid}";
                var hd_benren_susong = $("#hd_benren_susong").val();
                var hd_benren_jianding = $("#hd_benren_jianding").val();
                var hd_benren_gonggu = $("#hd_benren_gonggu").val();
                var hd_benren_zhusu = $("#hd_benren_zhusu").val();
                var hd_benren_luqiao = $("#hd_benren_luqiao").val();
                var hd_benren_ranyou = $("#hd_benren_ranyou").val();
                var hd_benren_qita = $("#hd_benren_qita").val();
                var hd_benren_huizong = $("#hd_benren_huizong").val();

                $.ajax({
                    url: "{:url('bushen/hepei/baocun_benren_hd')}",
                    data: {
                        bid: bid,
                        hd_benren_susong: hd_benren_susong,
                        hd_benren_jianding: hd_benren_jianding,
                        hd_benren_gonggu: hd_benren_gonggu,
                        hd_benren_zhusu: hd_benren_zhusu,
                        hd_benren_luqiao: hd_benren_luqiao,
                        hd_benren_ranyou: hd_benren_ranyou,
                        hd_benren_qita: hd_benren_qita,
                        hd_benren_huizong: hd_benren_huizong
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.msg(res.msg);
                        sub.onclick = '';
                    }
                })
            }
        </script>
        <div id="light1" class="white_content">
            <div class="conts">
                <div class="input">
                    <span>诊断病情</span>
                    <input type="text" name="bingqing" value="" readonly id="bingqing">
                </div>
                <div class="input">
                    <span>是否住院</span>
                    <select name="zhuyuan" id="zhuyuan" disabled>
                        <option value="是">是</option>
                        <option value="否">否</option>
                    </select>
                </div>
                <div class="input">
                    <span>住院天数</span>
                    <input type="text" name="zhuyuan_date" readonly value="" id="zhuyuan_date">
                </div>
                <div class="input">
                    <span>是否残疾</span>
                    <select name="canji" id="canji" disabled>
                        <option value="是">是</option>
                        <option value="否">否</option>
                    </select>
                </div>
            </div>
            <div class="content">
                <input type="hidden" name="bid" class="benid">
                <table class="layui-table" id="tabProducts">
                    <tr style="background: #4e73df;color:#fff;">
                        <td style="width: 66px;">选择</td>
                        <td>序号</td>
                        <!--<td>服务种类</td>-->
                        <td>费用类型</td>
                        <td>金额</td>
                        <td>数量</td>
                        <td>总价</td>
                        <td>核价金额</td>
                        <td>备注</td>
                    </tr>
                    <tr>
                        <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly
                                   value=""/></td>
                        <td><input type="text" class="xuhao6" name="xuhao" value="1" readonly/></td>
                        <!--<td><input type="text" name="type" readonly/></td>-->
                        <td><input type="text" name="leixing" readonly/></td>
                        <td><input type="text" name="price" readonly/></td>
                        <td><input type="text" name="num" readonly/></td>
                        <td><input type="text" name="money" readonly/></td>
                        <td><input type="text" name="hejia" readonly/></td>
                        <td><input type="text" name="beizhu"/></td>
                    </tr>
                </table>
                <table class="layui-table" id="hes">
                    <tr>
                        <td>小计</td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly value="" name="bren_money" id="bren_money" class="bren_money">
                        </td>
                        <td><input type="text" readonly value="" name="bren_hejia" id="bren_hejia" class="bren_hejia">
                        </td>
                        <td><input type="text" readonly></td>
                    </tr>
                </table>
                <div class="conts" style="display: flex;justify-content: center;">
                    <div class="">
<!--                        <button style="margin: 1%;margin-top:20px;" type="button" onclick="closeDialog1()">关闭</button>-->
                    </div>
                </div>
            </div>
        </div>
        <div id="fade1" class="black_overlay"></div>
        <script type="text/javascript">
            function openDialogs1(id) {
                // 1. 先打开弹窗（显示加载中状态）
                var $light2Content = $('#light1').contents(); // 先保存引用
                var layerIndex = layer.open({
                    type: 1,
                    title: '加载中...',
                    content: `
                    <div style="
                      position: absolute;
                      top: 50%;
                      left: 50%;
                      transform: translate(-50%, -50%);
                      text-align: center;
                    ">
                      <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                      <p style="margin-top: 10px">加载中...</p>
                    </div>
                  `,
                    end: function() {
                        // 弹窗关闭时，把内容放回 #light2
                        $('#light1').append($light2Content);
                    },
                    area: ['80%', '80%'],
                    shadeClose: false // 禁止点击遮罩关闭
                });
                $.ajax({
                    url: "{:url('bushen/lisuan/benrens')}",
                    data: {id: id},
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == true) {
                            var html = '';
                            if (res.data.renshang.length > 0) {
                                for (var i = 0; i < res.data.renshang.length; i++) {
                                    html += "<tr>" +
                                        "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' readonly name='id' value=" + res.data.renshang[i].id + "></td>" +
                                        "<td><input type='text' name='xuhao' readonly value=" + res.data.renshang[i].xuhao + "></td>" +
                                        "<td><input type='text' name='leixing' readonly value=" + res.data.renshang[i].leixing + "></td>" +
                                        "<td><input type='text' name='price' readonly value=" + res.data.renshang[i].price + "></td>" +
                                        "<td><input type='text' name='num' readonly value=" + res.data.renshang[i].num + "></td>" +
                                        "<td><input type='text' name='money' readonly value=" + res.data.renshang[i].money + "></td>" +
                                        "<td><input type='text' name='hejia' readonly value=" + res.data.renshang[i].hejia + "></td>" +
                                        "<td><input type='text' name='beizhu' readonly value=" + res.data.renshang[i].beizhu + "></td>" +
                                        "</tr>";
                                }
                            } else {
                                html += "<tr>" +
                                    "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' name='id' readonly value=''></td>" +
                                    "<td><input type='text' name='xuhao' value='1' readonly class='xuhao6'></td>" +
                                    "<td><input type='text' name='type' readonly value=''></td>" +
                                    "<td><input type='text' name='leixing' readonly value=''></td>" +
                                    "<td><input type='text' name='price' readonly value=''></td>" +
                                    "<td><input type='text' name='num' readonly value=''></td>" +
                                    "<td><input type='text' name='money' readonly value=''></td>" +
                                    "<td><input type='text' name='hejia' readonly value=''></td>" +
                                    "<td><input type='text' name='beizhu' readonly value=''></td>" +
                                    "</tr>";
                            }
                            $("#tabProducts tr").slice(1).remove();
                            $('#tabProducts').append(html);
                            $('#bingqing').val(res.data.benren.bingqing);
                            $('#zhuyuan').val(res.data.benren.zhuyuan);
                            $('#zhuyuan_date').val(res.data.benren.zhuyuan_date);
                            $('#canji').val(res.data.benren.canji);
                            $('#bren_money').val(res.data.benren.money);
                            $('#bren_hejia').val(res.data.benren.hejia);
                            $('.benid').val(res.data.benren.id);
                        }
                        layer.title('详情', layerIndex); // 修改标题
                        // $('#layui-layer' + layerIndex).find('.layui-layer-content').html($('#light1').html()); // 更新内容
                        $('#layui-layer' + layerIndex)
                            .find('.layui-layer-content')
                            .empty() // 先清空目标容器
                            .append($('#light1').contents()); // 移动 #light2 的子节点（不复制）
                    }
                })
            }

            function closeDialog1() {
                document.getElementById('light1').style.display = 'none';
                document.getElementById('fade1').style.display = 'none'
            }
        </script>
    </div>
    <script type="text/javascript">
        function test(obj) {

            var div1 = $('#div1');
            if (div1.css('display') === 'block') {
                div1.hide();  // 相当于 display: none
            } else {
                div1.show();  // 相当于 display: block
            }
        }
    </script>
    {if $lisuan4 != ''}
    {include file="bushen/jiean/lisuan4" /}
    {include file="bushen/jiean/buchangkuan4" /}
    {/if}
</div>